﻿using System.Net;

namespace Shared.Http.APIResult;

/// <summary>
/// API返回模型
/// </summary>
/// <typeparam name="T">数据类型</typeparam>
/// <param name="Code">业务状态码</param>
/// <param name="Message">描述信息</param>
/// <param name="Data">返回数据</param>
/// <param name="TraceId">链路追踪 ID</param>
public record ApiResult<T>
{
    public ApiStatusCode Code { get; init; }

    public T? Data { get; init; } = default;

    public IList<ErrorData>? Errors { get; init; } = [];

    public Guid TraceId { get; init; }
};

public record ErrorData
{
    public ErrorData() { }
    public ErrorData(object? id, string message)
    {
        Id = id;
        Message = message;
    }
    public ErrorData( string message)
    {
        Message = message;
    }
    public object? Id { get; init; }

    //public string ErrorCode { get; init; }

    public string Message { get; init; } = "";
};